package Comprehensive_03;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Demo1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"🐀", "🐂", "🐅", "🐇", "🐉", "🐍", "🐎", "🐏", "🐒", "🐓", "🐕", "🐖");
        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("请输入要操作的选项，1：开始点名，0：退出");
            switch (sc.next()) {
                case "1" -> getName(list);
                case "0" -> System.exit(0);
                default -> System.out.println("您输入的数字有误！！");
            }
        }
    }

//    private static<E> void getName(ArrayList<E> names) {
//        System.out.println("被点到的是：" + names.get(new Random().nextInt(names.size())));
//    }
    private static<E> void getName(ArrayList<E> names) {
        Collections.shuffle(names);
        System.out.println("被点到的是：" + names.get(0));
    }
}
